 
canvas.addEventListener("click", on_click);
canvas.addEventListener("keydown" , on_keydown, false);
canvas.addEventListener("keyup" , on_keyup, true);

window.addEventListener("click", on_click);

 function on_keydown(e) 	
	{		

		switch(e.which)
		{

			case 13: //enter
			checkBounds();
			break;
			
			case 65: //a, or 'left'
			player.movingLeft = true;
			break;

			case 68: //d, or 'right'
			player.movingRight = true;
			break;

			case 32: //space bar jump
			if(player.grounded && !(player.jumping))
			player.yvel -= player.jumpSpeed;
			break;


			default: break;
		}

	}

	function on_keyup(e) 	
	{		

		switch(e.which)
		{
			case 13: //enter
			break;
			
			case 65: //a, or 'left'
			player.movingLeft = false;
			break;

			case 68: //d, or 'right'
			player.movingRight = false;
			break;


			default: break;
		}

	}

    

 
	function on_click(e) 
	{ 
		canvas.focus();
	}
	  

	